package com.heima.crm.controller;

import com.heima.crm.common.result.Result;
import com.heima.crm.pojos.dtos.MenuPageDTO;
import com.heima.crm.pojos.entity.SysMenu;
import com.heima.crm.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/menu")
@RestController
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;

    //全部查询展示菜单(菜单名称,菜单状态)模糊
    @PostMapping("/list")
    public Result findList(@RequestBody MenuPageDTO dto){
        return sysMenuService.findList(dto);
    }

    //添加菜单,菜单类型,上级类目
    @PostMapping("/add")
    public Result add(@RequestBody SysMenu menu){
        return sysMenuService.add(menu);
    }

    //回显菜单信息
    @GetMapping("/findOne/{menuId}")
    public Result findById(@PathVariable Long menuId){
        return sysMenuService.findById(menuId);
    }

    //更新菜单
    @PutMapping("/update")
    public Result update(@RequestBody SysMenu menu){
        return sysMenuService.update(menu);
    }

    //删除菜单
    @DeleteMapping("/delete/{menuId}")
    public Result deleteById(@PathVariable Long menuId){
        return sysMenuService.deleteById(menuId);
    }

    //添加一个字段
    @PostMapping("parentName")
    public Result parentName(){
        return sysMenuService.parentName();
    }
}
